package com.xnx.bincker.leader.exception.login;

import com.xnx.bincker.leader.exception.SystemException;
import org.springframework.security.core.AuthenticationException;

/**
 * 登录失败异常
 */
public class LoginFailureException extends AuthenticationException implements SystemException {
    private int code;
    private String tip;

    public LoginFailureException() {
        this("用户登录失败");
    }

    public LoginFailureException(String message) {
        this(message, "账号或密码错误");
    }

    public LoginFailureException( String message, String tip) {
        this(0, message, tip);
    }

    protected LoginFailureException(int code, String message, String tip) {
        super(message);
        assert code < 1000;
        this.code = code;
        this.tip = tip;
    }

    @Override
    public int getCode() {
        return 3000 + code;
    }

    @Override
    public String getTip() {
        return tip;
    }
}
